import Equipment from './Equipment'

const install = function(Vue) {
  Vue.mixin({
    data() {
      if (this.$options.equipments instanceof Array) {
        const equipment = {
          equipment: {},
          label: {}
        }
        return {
          equipment
        }
      }
      return {}
    },
    created() {
      if (this.$options.equipments instanceof Array) {
        new Equipment(this.equipment).init(this.$options.equipments, () => {
          this.$nextTick(() => {
            this.$emit('equipmentReady')
          })
        })
      }
    }
  })
}

export default { install }
